import mongoose from 'mongoose'
import utils from '../utils'
const Schema = mongoose.Schema

const ShopProductsSchema = new Schema({
  name: String,
  describe: String,
  type: Number,
  previewImagePath: String,
  content: String,
  binding: String,
  price: Number,
  delPrice: Number,
  hotSearchFlag: Boolean,
  online: Boolean,
  createTime: {
    type: String,
    default: utils.currentTimeStamp()
  }
})

ShopProductsSchema.set('collection', 'ShopProducts')

// hidden some field
ShopProductsSchema.options.toJSON = {
  virtuals: true,
  versionKey: false,
  transform (doc, ret) {
    ret.id = ret._id
    delete ret._id
  }
}
mongoose.model('ShopProducts', ShopProductsSchema)
